# -*- encoding: utf-8 -*-
##############################################################################
#
##############################################################################

from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError

class stock_quant(models.Model):
    _inherit = 'stock.quant'

    @api.model
    def _quant_create_from_move(self, qty, move, lot_id=False, owner_id=False,
                                src_package_id=False, dest_package_id=False,
                                force_location_from=False, force_location_to=False):
        if force_location_from and force_location_from.usage == 'internal':
            raise ValidationError(u'对不起，来源库位里面库存不足。不允许转移！')
        elif move.location_id.usage == 'internal':
            raise ValidationError(u'对不起，来源库位里面库存不足。不允许转移！')
        return super(stock_quant,self)._quant_create_from_move(qty, move,lot_id=lot_id, owner_id=owner_id,
                                src_package_id=src_package_id, dest_package_id=dest_package_id,
                                force_location_from=force_location_from, force_location_to=force_location_to)